/*
 * Copyright (c) 2014 laidian. All Rights Reserved.
 * @author yaoyuming
 * @date  2020-05-06 15:39
 */
package com.yao.service;

import cn.hutool.core.lang.Console;
import com.yao.common.util.RedisUtils;
import com.yao.fin.baidu.BaiduApiConst;
import com.yao.fin.baidu.BaiduRedisUtils;
import com.yao.fin.baidu.TokenService;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author yaoyuming
 * @date 2020/05/06 15:39
 */
public class RedisService extends BaseService {

    @Test
    public void setAndGet(){
        String key = "yao";
        String value = "random-1";

        RedisUtils.set(key, value);

        String result = RedisUtils.get(key);

        Console.log("result = {}",result);
    }

    @Autowired
    private TokenService tokenService;

    @Test
    public void setToken(){
        String accessToken = tokenService.getAccessToken(BaiduApiConst.API_KEY, BaiduApiConst.SECRET_KEY);

        Console.log("从baidu获取token:{}",accessToken);

        BaiduRedisUtils.setToken(accessToken);

        String token = BaiduRedisUtils.getToken();

        Console.log("从redis获取token:{}", token);


    }
}